home *** CD-ROM | disk | FTP | other *** search
- { Qinit.inc - initialization for QWIK screen procedures ver 3.0, 08-31-87 }
- { This initialization routine checks for the type of video card and sets the
- parameters for the procedures: addresses, wait-for-retrace, and number of
- pages including system codes that can be used for testing in your program. }
-
- type
- Str80 = string[80]; { Type for Qwrites.inc }
-
- var
- Vmode: byte absolute $0040:$0049; { Video mode: Mono=7, Color=0-3 }
- EgaRows: byte absolute $0040:$0084; { Rows on screen (0-based) }
- EgaFontSize: integer absolute $0040:$0085; { Character cell height (1-based)}
- EgaInfo: byte absolute $0040:$0087; { EGA info. See QINIT.DOC }
- CRTcolumns: byte absolute $0040:$004A; { Number of CRT columns (1-based)}
- Page0seg, { Segment for page 0 }
- Qseg: integer; { Segment for Q writing }
- MaxPage: byte; { Maximum possible page }
- CardWait, { Wait-for-retrace for video card }
- Qwait, { Wait-for-retrace while Q writing }
- HavePS2: boolean; { Using some type of IBM PS/2 equip }
- EgaSwitches, { EGA card and monitor setup }
- SystemID,SubModelID, { Equipment ID. See QINIT.DOC }
- ActiveDD, { Active Display Device. }
- AltDD: byte; { Alternate Display Device. }
- PCCAltDD: integer; { Alt Display for PC Convertible. }
-
- const
- NoDisplay = $00; VgaMono = $07;
- MdaMono = $01; VgaColor = $08;
- CgaColor = $02; DCC9 = $09;
- DCC3 = $03; DCC10 = $0A;
- EgaColor = $04; McgaMono = $0B;
- EgaMono = $05; McgaColor = $0C;
- PgcColor = $06; Unknown = $FF;
-
- { Qinit - initializes Q global variables ver 3.0, 08-31-87 }
- procedure Qinit;
- begin
- Inline( {Assembly by Inline 08/29/87 13:24}
- {; -- Get computer model and submodel numbers --}
- $B4/$C0/ { mov ah,$C0 ; Set AH=$C0}
- $CD/$15/ { int $15 ; Do interrupt 15h}
- $72/$06/ { jc NoSupp ; Not supported}
- $26/ { es: ; Segment override}
- $8B/$57/$02/ { mov dx,[bx+$02] ; Get model and sub}
- $EB/$0C/ { jmp SHORT Modes ; Go check modes}
- { ;}
- $B9/$00/$F0/ {NoSupp: mov cx,$F000 ; Seg for system ID}
- $8E/$C1/ { mov es,cx ; Set segment}
- $26/ { es: ; Extra seg override}
- $8A/$16/$FE/$FF/ { mov dl,[$FFFE] ; DL= system ID}
- $88/$CE/ { mov dh,cl ; Set submodel=0}
- { ;}
- {; -- Check for original systems --}
- {; AX= Video segment (AL= 0)}
- {; BH= Video mode BL= Active display device}
- {; CH= MaxPage CL= CardWait}
- {; DH= SubModelID DL= SystemID}
- { ;}
- $31/$C9/ {Modes: xor cx,cx ; Set CX=0}
- $8E/$C1/ { mov es,cx ; Set ES=0}
- $26/ { es: ; Extra seg override}
- $8A/$3E/$49/$04/ { mov bh,by[$0449] ; Get video mode}
- $B3/$01/ { mov bl,$01 ; ActiveDD=MdaMono}
- $80/$FF/$07/ { cmp bh,$07 ; Mode=Monochrome?}
- $75/$05/ { jne Color ; no, assume color}
- { ;}
- $B8/$00/$B0/ { mov ax,$B000 ; Set AX=$B000}
- $EB/$12/ { jmp SHORT SetQ ;}
- { ;}
- $B8/$00/$B8/ {Color: mov ax,$B800 ; Set AX=$B800}
- $43/ { inc bx ; ActDD=CgaColor}
- $B5/$07/ { mov ch,$07 ; Set MaxPage=7}
- $38/$DF/ { cmp bh,bl ; Mode= 0 or 1?}
- $78/$08/ { js SetQ ; yes, 40 col mode}
- $D0/$ED/ { shr ch,1 ; no, MaxPage=3}
- $80/$FA/$FD/ { cmp dl,$FD ; PC Jr?}
- $74/$01/ { je SetQ ; yes,CardWait=false}
- $41/ { inc cx ; no, CardWait=true}
- { ;}
- $A3/>PAGE0SEG/ {SetQ: mov [>Page0Seg],ax ; Set Page0Seg}
- $88/$0E/>CARDWAIT/ { mov [>CardWait],cl ; Set CardWait}
- $88/$2E/>MAXPAGE/ { mov [>MaxPage],ch ; Set MaxPage}
- $A2/>HAVEPS2/ { mov [>HavePS2],al ; Set HavePS2=false}
- $88/$16/>SYSTEMID/ { mov [>SystemID],dl ; Save system ID}
- $88/$36/>SUBMODELID/ { mov [>SubModelID],dh ; Save SubModel ID}
- $88/$1E/>ACTIVEDD/ { mov [>ActiveDD],bl ; Set ActiveDispDev}
- $A2/>ALTDD/ { mov [>AltDD],al ; Set AltDispDev=0}
- { ;}
- {; -- Check for PC convertible LCD (5140) modes --}
- $80/$FA/$F9/ { cmp dl,$F9 ; PC convertible?}
- $75/$19/ { jne ChkDCC ; no}
- $B4/$15/ { mov ah,$15 ; Video types}
- $CD/$10/ { int $10 ; Call video BIOS}
- $A3/>PCCALTDD/ { mov [>PCCAltDD],ax ; Alt disp model#}
- $26/ { es: ; Extra seg override}
- $81/$3D/$40/$51/ { cmp wo[di],$5140 ; 5140h (LCD)?}
- $75/$7B/ { jne SetQ4 ; no}
- $80/$3E/>ACTIVEDD/$01/ { cmp by[>ActiveDD],$01; Emulate MdaMono?}
- $75/$6F/ { jne SetQ3 ; no}
- $B0/$03/ { mov al,$03 ; Set MaxPage=3}
- $EB/$68/ { jmp SHORT SetQ2 ;}
- { ;}
- {; -- Check for newer systems --}
- $B8/$00/$1A/ {ChkDCC: mov ax,$1A00 ; DispCombinationCode}
- $CD/$10/ { int $10 ; Call video BIOS}
- $3C/$1A/ { cmp al,$1A ; DCC supported?}
- $75/$1D/ { jne ChkEGA ; no, check for EGA}
- $C6/$06/>HAVEPS2/$01/ { mov by[>HavePS2],$01 ; Set HavePS2=true}
- $88/$1E/>ACTIVEDD/ { mov [>ActiveDD],bl ; Save ActiveDispDev}
- $88/$3E/>ALTDD/ { mov [>AltDD],bh ; Save AltDispDevice}
- $80/$FB/$07/ { cmp bl,$07 ; PS/2 active?}
- $78/$0B/ { js ChkEGA ; no}
- $B8/$00/$12/ { mov ax,$1200 ; Cursor emulate on}
- $B3/$34/ { mov bl,$34 ; Cursor emulation}
- $CD/$10/ { int $10 ; Call video BIOS}
- $B0/$07/ { mov al,$07 ; Set MaxPage=7}
- $EB/$42/ { jmp SHORT SetQ2 ;}
- { ;}
- $B4/$12/ {ChkEGA: mov ah,$12 ; Set AH for alt sel}
- $B3/$10/ { mov bl,$10 ; Set BL for EGA info}
- $CD/$10/ { int $10 ; Call video BIOS}
- $80/$FB/$10/ { cmp bl,$10 ; BL changed?}
- $74/$3F/ { jz SetQ4 ; no, no EGA either}
- $88/$0E/>EGASWITCHES/ { mov [>EgaSwitches],cl; Save EGA hardware}
- $31/$D2/ { xor dx,dx ; Set dx=0}
- $8E/$C2/ { mov es,dx ; Set es=0}
- $38/$16/>HAVEPS2/ { cmp by[>HavePS2],dl ; DDs not known?}
- $75/$19/ { jne Pages ; no, calc pages}
- $88/$F8/ { mov al,bh ; Copy EGA CC}
- $04/$04/ { add al,$04 ; Make into DCC}
- $26/ { es: ; Segment override}
- $F6/$06/$87/$04/$08/ { test by[$0487],$08 ; EGA active?}
- $74/$05/ { jz ActEGA ; yes}
- $A2/>ALTDD/ { mov [>AltDD],al ; no, save as AltDD}
- $EB/$20/ { jmp SHORT SetQ4 ; Done}
- { ;}
- $A2/>ACTIVEDD/ {ActEGA: mov [>ActiveDD],al ; Save it}
- $2C/$03/ { sub al,$03 ; Make AltDD}
- $A2/>ALTDD/ { mov [>AltDD],al ; Save it}
- $B0/$07/ {Pages: mov al,$07 ; Set MaxPage=7}
- $84/$DB/ { test bl,bl ; >64kb installed?}
- $75/$0A/ { jnz SetQ2 ; yes, MaxPage=7}
- $26/ { es: ; Segment override}
- $80/$3E/$49/$04/$02/ { cmp by[$0449],$02 ; 40 cols modes?}
- $78/$02/ { js SetQ2 ; yes, MaxPage=7}
- $D0/$E8/ { shr al,1 ; no, set MaxPage=3}
- { ;}
- {; -- Set Qwik global variables --}
- $A2/>MAXPAGE/ {SetQ2: mov [>MaxPage],al ; Set MaxPage}
- $C6/$06/>CARDWAIT/$00/ {SetQ3: mov by[>CardWait],$00; Set CardWait=false}
- $A0/>CARDWAIT/ {SetQ4: mov al,[>CardWait] ; Copy CardWait ...}
- $A2/>QWAIT/ { mov [>Qwait],al ; to Qwait}
- $A1/>PAGE0SEG/ { mov ax,[>Page0seg] ; Copy Page0seg ...}
- $A3/>QSEG); { mov [>Qseg],ax ; to Qseg}
- end;